// https://www.brbt.online/hfzzb/index.php
const { chromium, devices } = require("playwright")

const main = async () => {
	const browser = await chromium.launch()

	const phoneD = devices["iPhone 11"]
	const context = await browser.newContext({ ...phoneD })

	const page = await context.newPage()
	const url = "https://www.brbt.online/hfzzb/index.php"
	await page.goto(url)
	await page.screenshot({ path: "image.png" })

	// 等待 2s 加载
	await page.waitForTimeout(2000)
	const $ = page.$
	// page.$(document).ready(function () {
	function clearAllCookie() {
		var keys = document.cookie.match(/[^ =;]+(?=\=)/g)
		if (keys) {
			for (var i = keys.length; i--; )
				document.cookie =
					keys[i] + "=0;expires=" + new Date(0).toUTCString()
		}
	}
	clearAllCookie()
	$("input[value='231']").attr("checked", "checked")
	$("#submit_btn").removeClass("disabled").click()
	// })
}

main()
